#include <stdint.h>
#include <stdlib.h> //cstdlib和stdlib.h都可以
#include <stdio.h>  //cstdio和stdio.h都可以
#include <sys/socket.h>
#include <arpa/inet.h>
#include <string.h>
#include <signal.h>

#define PWM_CYSCLE 11111L
uint16_t pow_all = 0;

// 理论上应该是黄光，为0的话
uint16_t tc_rate = 5000;
// 输入为总的能量
void dali_hal_update_pwm_output(uint16_t pwm_value)
{
    uint8_t rate_y;
    uint8_t rate_w;
    uint16_t pwm_y;
    uint16_t pwm_w;
    uint32_t tmp;

    // printf("pwm_value %d \n", pwm_value);

    pow_all = pwm_value;

    rate_y = 100 - tc_rate / 111;
    rate_w = 100 - rate_y;

    tmp = (pwm_value * rate_y) / 100;
    pwm_y = tmp;

    pwm_w = pwm_value - pwm_y;

    printf("pwm_value %d rate_y %d rate_w %d pwm_y %d pwm_w %d \n", pwm_value, rate_y, rate_w, pwm_y, pwm_w);
}

// 输入为色温比例
//
void dali_hal_update_pwm_output_tc(uint16_t pwm_value)
{
}

void teset()
{

    printf("sdfaf\n");
}

int main()
{
    uint16_t i;

    printf("test\n");
    teset();

    for (i = 0; i < 11111; i++)
    {
        dali_hal_update_pwm_output(i);
    }
}